import { FC, useMemo } from 'react';
import { Input } from 'antd';
import { observer } from 'mobx-react';

import RbProTable, { RbProTableStore } from '@components/RbProTable';
import { Content } from '@components/Page';

import { TableAlignType } from '@/enumTypes/table';

const store = new RbProTableStore();

const TaskDoneList: FC = () => {
  /** 查询条配置列表 */
  const queryFromItems = useMemo(
    () => [
      {
        name: 'modelName',
        label: '流程名称',
        children: <Input />
      },
      {
        name: 'name',
        label: '任务节点',
        children: <Input />
      }
    ],
    []
  );

  /** 表格列配置 */
  const columns = useMemo(
    () => [
      {
        title: '流程名称',
        dataIndex: 'modelName',
        align: TableAlignType.center,
        width: 140
      },
      {
        title: '任务节点',
        dataIndex: 'name',
        align: TableAlignType.center,
        width: 140
      },
      {
        title: '任务处理时间',
        dataIndex: 'endTime',
        align: TableAlignType.center,
        sorter: true,
        width: 180
      },
      {
        title: '流程发起人',
        dataIndex: 'startUserName',
        align: TableAlignType.center,
        width: 140
      },
      {
        title: '任务接收时间',
        dataIndex: 'startTime',
        align: TableAlignType.center,
        sorter: true,
        width: 180
      },
      {
        title: '流程发起时间',
        dataIndex: 'instStartTime',
        align: TableAlignType.center,
        sorter: true,
        width: 180
      },
      {
        title: '持续时间',
        dataIndex: 'duration',
        align: TableAlignType.center,
        sorter: true,
        width: 180
      }
    ],
    []
  );
  return (
    <Content>
      <RbProTable
        rowKey="id"
        columns={columns}
        store={store}
        actionUrl="/flowable/procinst/doneList"
        sticky
        selectionType
        queryConfig={{
          queryFromItems,
          queryFormat: true
        }}
        toolBarRender={() => []}
      />
    </Content>
  );
};

export default observer(TaskDoneList);
